#include <stdio.h>

int func(int a)
{
    return a++;

    a = 1/a;
    return a;
}

void main()
{
    printf("%d\n", func(5));  // 5
}

#if 0

/*
 * intel
 */
0000000000001149 <func>:
    1149:	f3 0f 1e fa          	endbr64 
    114d:	55                   	push   %rbp				// rsp=rsp-8, (rsp)=rbp ===> subq $8,%rsp, movq %rbp,(%rsp)
    114e:	48 89 e5             	mov    %rsp,%rbp		// rbp=rsp
    1151:	89 7d fc             	mov    %edi,-0x4(%rbp)	// rbp-0x4 = edi
    1154:	8b 45 fc             	mov    -0x4(%rbp),%eax	// eax = rbp-0x4
    1157:	8d 50 01             	lea    0x1(%rax),%edx	// edx = rax+0x1
    115a:	89 55 fc             	mov    %edx,-0x4(%rbp)	// rbp-0x4 = edx = rax+0x1
    115d:	5d                   	pop    %rbp				// rbp=(rsp), rsp+8 ===> movq (%rsp),%rbp, addq $8, %rsp
    115e:	c3                   	retq					// ===> pop %rip

000000000000115f <main>:
    115f:	f3 0f 1e fa          	endbr64 
    1163:	55                   	push   %rbp					// rsp=rsp-8, rsp=rbp ===> subq $8,%rsp, movq %rbp,(%rsp)
    1164:	48 89 e5             	mov    %rsp,%rbp			// rbp=rsp
    1167:	bf 05 00 00 00       	mov    $0x5,%edi			// edi = 5
    116c:	e8 d8 ff ff ff       	callq  1149 <func>			// func(5)
    1171:	89 c6                	mov    %eax,%esi			// esi = eax = return value
    1173:	48 8d 3d 8a 0e 00 00 	lea    0xe8a(%rip),%rdi        # 2004 <_IO_stdin_used+0x4>
    117a:	b8 00 00 00 00       	mov    $0x0,%eax			// eax = 0
    117f:	e8 cc fe ff ff       	callq  1050 <printf@plt>	// printf(rdi,esi)
    1184:	90                   	nop
    1185:	5d                   	pop    %rbp			// rbp=(rsp), rsp+8 ===> movq (%rsp),%rbp, addq $8, %rsp
    1186:	c3                   	retq						// ===> pop %rip
    1187:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)		// 流水线指令优化
    118e:	00 00 

/*
 * arm-v8
 */
000000000040055c <func>:
  40055c:	d10043ff 	sub	sp, sp, #0x10	// sp = sp-0x10
  400560:	b9000fe0 	str	w0, [sp, #12]	// sp+12 = w0
  400564:	b9400fe0 	ldr	w0, [sp, #12]	// w0 = sp+12
  400568:	11000401 	add	w1, w0, #0x1	// w1 = w0+1
  40056c:	b9000fe1 	str	w1, [sp, #12]	// sp+12 = w1
  400570:	910043ff 	add	sp, sp, #0x10	// sp = sp+0x10
  400574:	d65f03c0 	ret

0000000000400578 <main>:
  400578:	a9bf7bfd 	stp	x29, x30, [sp, #-16]!	// sp=sp-16, sp=x29=fp, sp+8=x30=lr
  40057c:	910003fd 	mov	x29, sp					// sp = x29
  400580:	528000a0 	mov	w0, #0x5                   	// #5
  400584:	97fffff6 	bl	40055c <func>		// func(5)
  400588:	2a0003e1 	mov	w1, w0				// w1 = return value
  40058c:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  400590:	91196000 	add	x0, x0, #0x658		// 40658
  400594:	97ffffaf 	bl	400450 <printf@plt>	// %d\n, w1=5
  400598:	d503201f 	nop
  40059c:	a8c17bfd 	ldp	x29, x30, [sp], #16		// x29=fp=sp, x30=lr=sp+8, sp=sp+16
  4005a0:	d65f03c0 	ret
  4005a4:	00000000 	.inst	0x00000000 ; undefined

#endif
